# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'

target 'DemoApp' do
  # Uncomment the next line if you're using Swift or would like to use dynamic frameworks
  # use_frameworks!

  # Pods for DemoApp
  pod 'AppCenter/Crashes', '~> 4.4.1'
  pod 'AppCenter/Analytics', '~> 4.4.1'
  pod 'AppCenterReactNativeShared', '~> 4.4.1'

  platform :ios, '9.0'

  # This commented line is to avoid react-native link adding an optional dependency that is way too heavy.
  # pod 'RNGestureHandler', :path => '../node_modules/react-native-gesture-handler'

end

post_install do |installer|

  # Fix for XCode 12.5 beta
  # https://github.com/facebook/react-native/issues/31412#issuecomment-855594504
  find_and_replace("../node_modules/react-native/React/CxxBridge/RCTCxxBridge.mm",
  "_initializeModules:(NSArray<id<RCTBridgeModule>> *)modules", "_initializeModules:(NSArray<Class> *)modules")
end

def find_and_replace(dir, findstr, replacestr)
  Dir[dir].each do |name|
      text = File.read(name)
      replace = text.gsub(findstr,replacestr)
      if text != replace
          puts "Fix: " + name
          File.open(name, "w") { |file| file.puts replace }
          STDOUT.flush
      end
  end
  Dir[dir + '*/'].each(&method(:find_and_replace))
end
